﻿#查找路径下面所有源文件
aux_source_directory(. SRC_LIST)

#引用库名
set(MY_LIBS commonLibG3Log)
set(LINK_LIST "")
foreach(x ${MY_LIBS})
    list (APPEND LINK_LIST debug ${x}_gd optimized ${x})
endforeach()

IF(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
	message( STATUS "cmake for GCC " )
   IF (APPLE)
       set(CMAKE_CXX_FLAGS   "${CMAKE_CXX_FLAGS} -Wall -Wunused -std=c++14  -pthread")
   ELSEIF (MINGW)
       set(CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} -Wall -Wunused -std=c++14  -pthread")
       set(PLATFORM_LINK_LIBRIES dbghelp)

       # deal with ERROR level conflicts with windows.h
       ADD_DEFINITIONS (-DNOGDI)
   ELSE()
       set(PLATFORM_LINK_LIBRIES rt)
       set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -rdynamic -Wunused -std=c++14 -pthread -lrt")
   ENDIF()
   message( STATUS ${CMAKE_CXX_FLAGS} )
ELSEIF(MSVC)
   set(PLATFORM_LINK_LIBRIES dbghelp)
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8") # source code already in utf-8, force it for compilers in non-utf8_windows_locale
   # ERROR level conflicts with windows.h
   ADD_DEFINITIONS (-DNOGDI)
   # support AMD proc on vc2015
   if(${CMAKE_CL_64} STREQUAL "0")
       set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /arch:IA32")
   endif()
   message( STATUS ${CMAKE_CXX_FLAGS} )
endif()


#生成exe文件
ADD_EXECUTABLE(Log ${SRC_LIST})

#添加库
target_link_libraries(Log ${LINK_LIST})

#设置预编译
SET_TARGET_PROPERTIES(Log PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT "stdafx.h")
cotire(Log)

#设置目录
set_target_properties(Log PROPERTIES FOLDER "Test")
install(TARGETS Log 
        RUNTIME DESTINATION ${PROJECT_BINARY_DIR}/bin)


